package com.xbdun.web.bmp;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;

import com.xbdun.comweb.bmp.BaseApplicationRunner;
import com.xbdun.comweb.bmp.session.IUserAuth;
import com.xbdun.comweb.bmp.util.UserInfoUtil;
import com.xbdun.comweb.bmp.util.WebCommonUtil;
import com.xbdun.web.bmp.service.UserAuthService;

@SpringBootApplication
@EnableRedisHttpSession
@EnableCaching
@EnableScheduling
public class WebApplication extends BaseApplicationRunner {
	@Value("${xbdun.url.bmp}")
	private String bmpUrl;//本地地址
	@Value("${xbdun.url.validatebmp}")
	private String valiUrl;//通用验证平台的网络地址
	@Autowired
	IUserAuth iUserAuth;
	public static void main(String[] args) {
		SpringApplication.run(WebApplication.class, args);
	}
	@Override
	public void run(String... args) throws Exception {
		super.run(args);
		WebCommonUtil.setBaseUrl(bmpUrl);//设置当前系统的地址
		WebCommonUtil.setWEB_VALIDATE_URL(valiUrl);//第三方通用平台地址
		UserInfoUtil.setIUserAuth(iUserAuth);//用户工具获取当前用户权限
	}
	@Bean
	public IUserAuth createIUserAuth(){
		return new UserAuthService();
	}
}